package com.coreJava.test01;

import java.util.concurrent.*;

/**
 * 作者: LCG
 * 日期: 2019/9/1 10:58
 * 描述:
 */
public class Test01 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //线程池的使用
        ExecutorService executorService = Executors.newSingleThreadExecutor();

        Future<String> submit = executorService.submit(new Callable<String>() {

            public String call() throws Exception {
                System.out.println("---------运行中----");
                Thread.sleep(10000);
                System.out.println("--------运行结束-----");
                return "oooooo";
            }
        });

        System.out.println("--------->外部程序");
        String s = submit.get();

        System.out.println("---外部程序获取结果--->"+s);

        executorService.shutdown();
    }
}
